<script setup lang="ts">
import dayjs from 'dayjs';
import { ref } from 'vue';
import AuthBar from '@/components/authBar/index.vue';
import { dictVal2Text } from '@/utils/dict.utils';
import { withQueryString } from '@/utils/router.utils';

const sortList = ref([
  {
    label: '默认',
    value: 1
  },
  {
    label: '医生数量',
    value: 2
  }
]);

const sortType = ref(1);

const searchTypeList = ref([
  {
    id: '1',
    title: '内科',
    desc: '包含心内科、消化内科、呼吸内科等',
    doctorNo: 24
  },
  {
    id: '2',
    title: '外科',
    desc: '包含普通外科、骨科、神经外科等',
    doctorNo: 16
  },
  {
    id: '3',
    title: '妇产科',
    desc: '包含妇科、产科、生殖医学等'
  },
  {
    id: '4',
    title: '儿科',
    desc: '包含小儿内科、小儿外科等'
  },
  {
    id: '5',
    title: '眼科',
    desc: '眼部疾病诊断与治疗'
  }
]);

function handleClick(item) {
  uni.navigateTo({
    url: withQueryString('/pages/informationQuery/departmentDetail', {
      id: item.id
    })
  });
}
</script>

<template>
  <view class="page flex-col">
    <AuthBar />
    <view class="flex-1 overflow-auto">
      <view class="page-content mx-48 mt-32">
        <view class="page-title flex items-center justify-between">
          科室信息查询结果
          <view class="search-time">
            查询时间：{{ dayjs().format("YYYY/MM/DD HH:mm:ss") }}
          </view>
        </view>
        <view class="page-subtitle flex items-center justify-between">
          共找到6条结果
          <view class="search-sort flex items-center">
            排序：
            <view class="relative w-166">
              <wd-picker v-model="sortType" :columns="sortList" title="选择排序类型" use-default-slot>
                <wd-input :placeholder="dictVal2Text(sortType, sortList)" readonly />
              </wd-picker>

              <view class="select-arrow">
                <wd-icon name="arrow-down" size="22px" color="var(--primary)" />
              </view>
            </view>
          </view>
        </view>
        <view class="search-group">
          <view v-for="item in searchTypeList" :key="item.title" class="search-item" @click="handleClick(item)">
            <view class="flex items-center justify-between">
              <view>
                <view class="search-item__title">
                  {{ item.title }}
                </view>
                <view class="search-item__desc">
                  {{ item.desc }}
                </view>
              </view>
              <view class="search-item__cover">
                <i class="iconfont icon-a-rongqi5" />
              </view>
            </view>
            <view class="search-item__content">
              <view class="mt-28 flex items-center">
                <view class="doctor-num__tag">
                  医生24名
                </view>
                <view class="search-item__detail">
                  查看详情 <wd-icon name="arrow-right" size="32px" />
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<route type="page" lang="json5">
{
  layout: 'default',
  style: {
    navigationBarTitleText: '科室信息',
    navigationStyle: 'custom'
  }
}
</route>

<style lang="scss" scoped>
.page {
  height: 100%;
  background-color: var(--bg-color);

  .page-content {
    border: 2px solid #e6effd;
    background: #d8e7ff;
    border-radius: 20px;
    padding: 40px 52px;
  }

  .page-title {
    font-size: 48px;
    font-weight: bold;
    color: var(--text-color);

    .search-time {
      font-size: 28px;
      color: #686869;
      font-weight: normal;
    }
  }

  .page-subtitle {
    font-size: 30px;
    color: var(--secondary-text-color);

    .search-sort {
      position: relative;
      --wot-input-inner-height: 60px;
      --wot-input-fs: 24px;
      --wot-input-placeholder-color: #767676;

      :deep(.wd-input) {
        border-radius: 8px;
        background: #eff5ff;
        border: 1px solid #ffffff;
        box-sizing: border-box;
        padding-left: 20px;

        &:after {
          background: transparent;
        }
      }

      .select-arrow {
        position: absolute;
        right: 24px;
        top: 50%;
        transform: translateY(-50%);
      }
    }
  }

  .search-group {
    margin-top: 36px;

    .search-item {
      background: #f5f9ff;
      padding: 43px 40px;
      border-radius: 20px;
      margin-bottom: 20px;

      .search-item__title {
        font-size: 48px;
        font-weight: bold;
        color: var(--text-color);
      }

      .search-item__desc {
        font-size: 30px;
        color: #686869;
        margin-top: 14px;
      }

      .search-item__cover {
        @apply flex-center;
        background: #e1ecff;
        border-radius: 20px;
        width: 114px;
        height: 124px;

        .iconfont {
          color: var(--primary);
          font-size: 74px;
        }
      }

      .search-item__content {
        .doctor-num__tag {
          background: #dfecff;
          color: var(--primary);
          font-size: 32px;
          border-radius: 100px;
          padding: 4px 30px;
        }

        .search-item__detail {
          color: var(--primary);
          font-size: 32px;
          margin-left: 30px;
        }
      }

      &:hover,
      &:active {
        background-color: var(--primary);

        .search-item__title,
        .search-item__desc,
        .search-item__detail {
          color: #fff;
        }
      }
    }
  }
}
</style>
